<template>
    <div class="write-info">
        <nut-form>
            <nut-form-item label="银行卡号">
                <nut-input v-model="card" type="number" class="nut-input-text" placeholder="请输入银行卡号" />
            </nut-form-item>
            <nut-form-item label="姓名">
                <nut-input v-model="name" type="text" class="nut-input-text" placeholder="请输入姓名" />
            </nut-form-item>
            <nut-form-item label="金额">
                <nut-input v-model="num" type="number" class="nut-input-text" placeholder="请输入金额" />
            </nut-form-item>
            <nut-form-item label="电话">
                <nut-input v-model="phone" type="number" class="nut-input-text" placeholder="请输入电话" />
            </nut-form-item>
        </nut-form>
        <div class="save-info">
            <nut-button shape="square" color="#F0A93F" style="border-radius: 10rpx;" block type="info"
                @click="saveInfo">提交申请</nut-button>
        </div>
    </div>
</template>

<script lang="ts">
import Taro, { useRouter } from '@tarojs/taro';
import { Right } from '@nutui/icons-vue-taro';
import { reactive, toRefs, onMounted, onUnmounted } from 'vue';
import { applyMoney, } from '../../../../api/index'
export default {
    components: {
        Right
    },
    setup() {
        const data = reactive({
            card: '',
            name: '',
            num: '',
            phone: '',
            userId: '',
        });
        const saveInfo = () => {
            applyMoney({ card: data.card, name: data.name, num: data.num, phone: data.phone, userId: data.userId }).then(res => {
                if (res.code == 0) {
                    Taro.showToast({
                        title: '已提交申请',
                        icon: 'success',
                        duration: 2000
                    })
                    Taro.redirectTo({ url: '/packageA/pages/manage/index' })
                }
            })
        }
        onMounted(() => {
            Taro.getStorage({
                key: 'user',
                success: function (res) {
                    data.userId = res.data.uuid
                }
            })
        });

        return {
            ...toRefs(data), saveInfo,
        }
    }
};
</script>


<style lang="scss">
.write-info {
    .nut-cell {
        .nut-cell {
            padding: 0;
        }
    }

    .nut-form-item__label {
        color: #0F1233;
        font-size: 26rpx;
    }

    .input-text {
        text-align: right !important;
        color: #2C2E4C;
    }

    .readonly {
        color: gray;
    }

    .info-btn {
        white-space: nowrap;

        .nut-button {
            width: 120rpx;
            height: 65rpx;
            border: none;
            border-radius: 0;
            background: transparent;
            margin-left: 350rpx;
        }
    }
}

.save-info {
    position: fixed;
    bottom: 0;
    left: 0;
    background: #fff;
    padding: 20rpx 40rpx;
    box-sizing: border-box;
    width: 100%;
    text-align: center;
}
</style>